package com.android.infantschool.model.mvp.presenter;

import com.android.infantschool.bean.BaseBean;
import com.android.infantschool.model.mvp.model.ApiListener;
import com.android.infantschool.model.mvp.model.ApiModel;
import com.android.infantschool.model.mvp.model.ApiModelImpl;
import com.android.infantschool.model.mvp.model.OnApiListener;
import com.android.infantschool.model.mvp.view.ClockClockView;

import java.util.Map;

/**
 * @author Administrator
 * @particulars
 * @time 2019\7\24 0024 8:54
 * @class describe
 */
public class ClockClockPresenterImpl implements ClockClockPresenter, ApiListener {

    private ClockClockView clockClockView;
    private ApiModel apiModel;

    public ClockClockPresenterImpl(ClockClockView clockClockView) {
        this.clockClockView = clockClockView;
        this.apiModel = new ApiModelImpl();
    }

    @Override
    public void onDestroy() {
        clockClockView = null;
    }

    @Override
    public void getClockClock(Map<String, String> map, int type) {
        apiModel.getClockingClocking(this, map, type);
    }

    @Override
    public void onError(String error, int type) {
        if (clockClockView != null) {
            clockClockView.errorClockClock(error, type);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean, int type) {
        if (clockClockView != null) {
            clockClockView.successClockClock(baseBean, type);
        }
    }
}